package com.study.cloud.gateway.core.filter;

import com.study.cloud.gateway.core.context.GatewayContext;

/**
 * 过滤器顶级接口
 * @author wangwancheng
 * @create 2025/7/20 14:40
 */
public interface FilterInterface {

    /**
     * 过滤器逻辑
     * @param context
     * @throws Exception
     */
    void doFilter(GatewayContext context) throws Exception;

    /**
     * 排序
     * @return
     */
    default int getOrder(){
        Filter filter = this.getClass().getAnnotation(Filter.class);
        if (filter != null){
            return filter.order();
        }
        //值越大 优先级越低
        return Integer.MAX_VALUE;
    };
}
